/*
 * @Author: 2112778581 2112778581@qq.com
 * @Date: 2023-10-16 10:13:29
 * @LastEditors: fengshan525 2735332396@qq.com
 * @LastEditTime: 2023-10-17 19:47:39
 * @FilePath: \pra\libs\db\src\models\news.model.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { ApiProperty } from '@nestjs/swagger';
import { modelOptions, prop } from '@typegoose/typegoose';
import { IsNotEmpty, Allow } from 'class-validator';

@modelOptions({
  // 自动为每个属性添加时间戳
  schemaOptions: {
    timestamps: true,
  },
})
export class Image {
  @ApiProperty({ description: 'url' })
  @IsNotEmpty({ message: '链接不能为空' })
  @prop()
  url: string;

  @ApiProperty({ description: 'name' })
  @IsNotEmpty({ message: '图片名称不能为空' })
  @prop()
  filename: string;

  @ApiProperty({ description: 'category' })
  @IsNotEmpty({ message: '图片分类不能为空' })
  @prop({default:'all'})
  categoryCode: string; // 图片分类（聚合查询使用）

  @Allow()
  _id: string;

  @Allow()
  createdAt: string;

  @Allow()
  updatedAt: string;

  @Allow()
  __v: string;
}
